home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr05 / mswlogo3.zip / MSWLOGO.ZIP / EXAMPLES.ZIP / CLOCK < prev    next >
Text File  |  1993-04-16  |  2KB  |  115 lines

  1. ;
  2. ; Function:
  3. ;
  4. ; Simple graphical real time clock.
  5. ;
  6. ; To run:
  7. ;
  8. ; load "clock
  9. ; Call CLOCK clicks
  10. ;
  11. ; Example:
  12. ;
  13. ; clock 1000
  14. ;
  15. ; Problem:
  16. ;
  17. ; On slow machines it works good. On fast machines it needs to check
  18. ; to see if a second has gone by before redrawing second hand.
  19. ;
  20. to clock :seconds
  21. cs
  22. ht
  23. drawface
  24. make "sec 0
  25. make "min 0
  26. make "hour 0
  27. plottimehour :hour
  28. plottimemin :min
  29. plottimesec :sec
  30. repeat :seconds ~
  31.   [ ~
  32.   make "thetime gettime ~
  33.   make "nhour first :thetime ~
  34.   make "thetime butfirst :thetime ~
  35.   make "nmin first :thetime ~
  36.   make "thetime butfirst :thetime ~
  37.   make "nsec first :thetime ~
  38.   plottimesec :sec ~
  39.   if not equalp :min :nmin~
  40.     [~
  41.     plottimemin :min ~
  42.     if not equalp :hour :nhour~
  43.       [~
  44.       plottimehour :hour ~
  45.       plottimehour :nhour ~
  46.       ]~
  47.     plottimemin :nmin ~
  48.     ]~
  49.   plottimesec :nsec ~
  50.   make "hour :nhour~
  51.   make "min :nmin~
  52.   make "sec :nsec~
  53.   ]
  54. end
  55.  
  56. to drawface
  57. setheading 30
  58. pu
  59. repeat 12 ~
  60.   [~
  61.   fd 120 ~
  62.   setx xcor-12 ~
  63.   sety ycor+12 ~
  64.   label repcount ~
  65.   setx xcor+12 ~
  66.   sety ycor-12 ~
  67.   bk 120 ~
  68.   rt 30 ~
  69.   ]
  70. end
  71.  
  72. to gettime
  73. make "thetime parse time
  74. make "thetime butfirst :thetime
  75. make "thetime butfirst :thetime
  76. make "thetime butfirst :thetime
  77. make "thetime first :thetime
  78. make "thetime parse map "oo :thetime
  79. output :thetime
  80. end
  81.  
  82. to oo :a
  83. if equalp ": :a [output char 32] [output :a]
  84. end
  85.  
  86. to plottimehour :hour
  87. penreverse
  88. setpensize [5 5]
  89. setheading :hour*30
  90. pd
  91. fd 50
  92. pu
  93. bk 50
  94. end
  95.  
  96. to plottimemin :min
  97. penreverse
  98. setpensize [2 2]
  99. setheading :min*6
  100. pd
  101. fd 100
  102. pu
  103. bk 100
  104. end
  105.  
  106. to plottimesec :sec
  107. penreverse
  108. setpensize [1 1]
  109. setheading :sec*6
  110. pd
  111. fd 100
  112. pu
  113. bk 100
  114. end
  115.